/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ua.yandex.sumofseries.utilconcurrent;

import java.util.concurrent.Callable;

/**
 *
 * @author vlad
 */
public class CalcSmallInterval implements Callable<Double> {
    
    private static final double STEP = 10e-4;
    
    private long start;
    private long end;
    
    public CalcSmallInterval(long start, long end) {
        this.start = start;
        this.end = end;
        if(start > end) {
            long temp;
            temp = this.start;
            this.start = end;
            this.end = temp;
        }
    }
    
    
    @Override
    public Double call() {
        double sum;
        sum = 0;
        for(long i = start; i <= end; i++) {
            sum += Math.sin(i * STEP) * Math.cos(i * STEP);
        }
        return sum;
    }
    
}
